double Round(double x)
{
    if (x == 0)
        return 0;
    else if (x > 0)
    {
        double mid = floor(x) + 0.5;
        return x >= mid ? ceil(x) : floor(x);
    }
    else
    {
        x = -x;
        double mid = floor(x) + 0.5;
        x = x >= mid ? ceil(x) : floor(x);
        return 0 - x;
    }
}